package com.belarus.kamianiec.photo.photoSite.web.inner;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import org.zkoss.bind.BindUtils;
import org.zkoss.bind.annotation.NotifyChange;

import com.belarus.kamianiec.photo.photoSite.domain.News;

public class NewsAppVm {

	private String title;
	private List<News> newsList;

	private final static String titleName = "title";
	private final static String newsListName = "newsList";

	public NewsAppVm() {
		title = "NEWS";
		News news1 = new News();
		news1.setTitle("news1");
		news1.setDateAdded("2010-10-10");
		news1.setBody("news1news1news1news1news1news1news1news1news1news1news1news1news1news1news1news1news"
				+ "1news1news1news1news1news1news1news1news1news1news1news1news1news1news1news1news1news1news"
				+ "1news1news1news1news1news1news1news1news1news1news1news1news1news1news1news1news1news1news"
				+ "1news1news1news1news1news1news1news1news1news1news1news1news1news1news1news1news1news1news"
				+ "1news1news1news1news1news1news1news1news1news1news1news1news1news1news1news1news1news1news1");
		news1.setMultiline(false);
		News news2 = new News();
		news2.setTitle("news2");
		news2.setDateAdded("2011-11-11");
		news2.setBody("news2news2news2news2news2news2news2news2news2news2news2news2news2news2news2news2news"
				+ "2news2news2news2news2news2news2news2news2news2news2news2news2news2news2news2news2news2news"
				+ "2news2news2news2news2news2news2news2news2news2news2news2news2news2news2news2news2news2news"
				+ "2news2news2news2news2news2news2news2news2news2news2news2news2news2news2news2news2news2news"
				+ "2news2news2news2news2news2news2news2news2news2news2news2news2news2news2news2news2news2news2");
		news2.setMultiline(false);
		News news3 = new News();
		news3.setTitle("news3");
		news3.setDateAdded("2012-12-12");
		news3.setBody("news3news3news3news3news3news3news3news3news3news3news3news3news3news3news3news3news"
				+ "3news3news3news3news3news3news3news3news3news3news3news3news3news3news3news3news3news3news"
				+ "3news3news3news3news3news3news3news3news3news3news3news3news3news3news3news3news3news3news"
				+ "3news3news3news3news3news3news3news3news3news3news3news3news3news3news3news3news3news3news"
				+ "3news3news3news3news3news3news3news3news3news3news3news3news3news3news3news3news3news3news");
		news3.setMultiline(false);
		newsList = new ArrayList<News>(Arrays.asList(news1, news2, news3));
	}

	/**
	 * @return the title
	 */
	public String getTitle() {
		return title;
	}

	/**
	 * @param title
	 *            the title to set
	 */
	@NotifyChange(titleName)
	public void setTitle(String title) {
		this.title = title;
		BindUtils.postNotifyChange(null, null, this, titleName);
	}

	/**
	 * @return the newsList
	 */
	public List<News> getNewsList() {
		return Collections.unmodifiableList(newsList);
	}

	/**
	 * @param newsList
	 *            the newsList to set
	 */
	@NotifyChange(newsListName)
	public void setNewsList(List<News> newsList) {
		this.newsList = newsList;
		BindUtils.postNotifyChange(null, null, this, newsListName);
	}
}
